package com.harmontronics.hanma.paas.paas.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.harmontronics.hanma.paas.paas.domain.app.entity.HmPage;
import com.harmontronics.hanma.paas.paas.domain.app.entity.valueobject.I18nKeyEnum;
import com.harmontronics.hanma.paas.paas.domain.iam.service.HmMenuService;
import com.harmontronics.hanma.paas.paas.exception.ErrorKeyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.harmontronics.hanma.paas.paas.domain.app.service.HmPageService;

import java.util.List;


/**
 * @author ldb
 */
@Service("hmPageAppService")
@DS("#header.App-Unique")
public class HmPageAppService extends HmPageService {


    @Autowired
    private HmMenuService hmMenuService;

    @Override
    public void remove(List<Long> ids){
        for(Long id:ids){
            if(hmMenuService.isPageReferred(id)){
                throw new ErrorKeyException(I18nKeyEnum.PAGE_REFERRED_BY_MENU);
            }
        }
        super.remove(ids);
    }
}